import Vue from 'vue';
import iView from 'iview';
import VueRouter from 'vue-router';
import Util from '../libs/util';
import 'iview/dist/styles/iview.css';

Vue.use(iView);
Vue.use(VueRouter);

const router = new VueRouter({
    mode: 'hash',
    routes: [{
	    path: '/',
	    meta: {title: '查询活动'},
	    component: (resolve) => require(['../views/activity/search.vue'], resolve)    	
    },{
        path: '/activity/search',
        meta: {title: '查询活动'},
        component: (resolve) => require(['../views/activity/search.vue'], resolve)        
    },{
        path: '/activity/create',
        meta: {title: '创建活动'},
        component: (resolve) => require(['../views/activity/create.vue'], resolve)    
    },{
        path: '/coupon/search',
        meta: {title: '创建活动'},
        component: (resolve) => require(['../views/coupon/search.vue'], resolve)    
    },{
        path: '/coupon/create',
        meta: {title: '创建活动'},
        component: (resolve) => require(['../views/coupon/create.vue'], resolve)    
    }]	
});

router.beforeEach((to, from, next) => {
    iView.LoadingBar.start();
    Util.title(to.meta.title);
    next();
});

router.afterEach(() => {
    iView.LoadingBar.finish();
    window.scrollTo(0, 0);
});

export default router;